package Client;


import SQL.Connections;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Vector;

//支付管理
public class PaymentManagement extends JFrame{
    private JPanel panel1;
    private JLabel titleLabel;
    private JButton 确认Button;
    private JButton 返回Button;
    private JButton 添加Button;
    private JButton 删除Button;
    private JTable table1;
    public static JFrame f;


    static String s[];

    private static String user;

    private Connection con;
    private Statement stm;
    private ResultSet rs;
    private Connections connections = new Connections();
    Vector<Vector> values;
    Vector<String> name;
    public String classNo;


    public PaymentManagement() {
        返回Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //跳转
                PassengerHome passengerHome=new PassengerHome();
                passengerHome.initialize();
                f.dispose();
            }
        });
        确认Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //跳转
                PassengerHome passengerHome=new PassengerHome();
                passengerHome.initialize();
                //JOptionPane.showMessageDialog(panel1,"购票成功","提示",JOptionPane.WARNING_MESSAGE);
                f.dispose();
            }
        });
        添加Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
        删除Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
    }


    private static void initialize() {
        JFrame frame = new JFrame("PaymentManagement");
        frame.setContentPane(new PaymentManagement().panel1);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);//设置屏幕居中
        frame.setVisible(true);


        //保存用户名
        //PaymentManagement.user = user;

    }

    private void createUIComponents() {
        // TODO: place custom component creation code here
        titleLabel = new JLabel(new ImageIcon("wallet.png"));


        String phone="13012341234";
        values=new Vector<>();
        name=new Vector();
        values=Connections.queryData("SELECT * FROM creditcard WHERE PhoneNumber='"+phone+"'");
        name.add("银行卡号");
        name.add("手机号");
        name.add("余额");

        TableModel d=new DefaultTableModel(values,name);
        table1= new JTable(values,name);
        table1.setRowSelectionInterval(0,0);
    }

    public static void main(String[] args) {
        initialize();
    }

}


